﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <!-- Resource dictionary entries should be defined here. -->


    <Style TargetType="{x:Type ContextMenu}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Foreground" Value="{DynamicResource MetroMenuText}"/>
        <Setter Property="FontSize" Value="12" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContextMenu}">
                    <ControlTemplate.Resources>
                        
                        <ControlTemplate x:Key="MenuItem.Item" TargetType="{x:Type MenuItem}">
                            <Border x:Name="Border" Background="{DynamicResource MetroMenuBg}" Padding="10,2,10,2">
                                <ContentPresenter ContentSource="Header" RecognizesAccessKey="True" RenderOptions.ClearTypeHint="Enabled" />
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="Border" Property="Background" Value="{DynamicResource MetroMenuItemHover}"/>
                                </Trigger>
                                <Trigger Property="IsHighlighted" Value="True">
                                    <Setter TargetName="Border" Property="Background" Value="{DynamicResource MetroMenuItemHover}"/>
                                </Trigger>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter TargetName="Border" Property="Opacity" Value="0.5"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>

                        <ControlTemplate x:Key="MenuItem.Header" TargetType="{x:Type MenuItem}">
                            <Border x:Name="Border" Background="{DynamicResource MetroMenuBg}" Padding="10,2,10,2">
                                <Grid>
                                    <ContentPresenter ContentSource="Header" RecognizesAccessKey="True" RenderOptions.ClearTypeHint="Enabled" />
                                    <Path Width="4" Height="5" Stretch="Fill" Fill="{DynamicResource MetroMenuItemArrow}" Data="{StaticResource PathRightArrow}" HorizontalAlignment="Right"/>
                                    <Popup Name="PART_Popup" Placement="Right" HorizontalOffset="8" AllowsTransparency="True" IsOpen="{TemplateBinding IsSubmenuOpen}" PopupAnimation="Fade">
                                        <Grid Margin="8" MinWidth="150">
                                            <Canvas Background="{DynamicResource MetroMenuBg}" Effect="{DynamicResource MetroDropShadow}" />
                                            <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" Margin="1,4"/>
                                        </Grid>
                                    </Popup>
                                </Grid>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="Border" Property="Background" Value="{DynamicResource MetroMenuItemHover}"/>
                                </Trigger>
                                <Trigger Property="IsHighlighted" Value="True">
                                    <Setter TargetName="Border" Property="Background" Value="{DynamicResource MetroMenuItemHover}"/>
                                </Trigger>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter TargetName="Border" Property="Opacity" Value="0.5"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>

                        <Style TargetType="{x:Type MenuItem}">
                            <Style.Triggers>
                                <Trigger Property="Role" Value="TopLevelHeader">
                                    <Setter Property="Template"
					              Value="{StaticResource MenuItem.Header}"/>
                                </Trigger>
                                <Trigger Property="Role" Value="TopLevelItem">
                                    <Setter Property="Template"
					              Value="{StaticResource MenuItem.Item}"/>
                                </Trigger>
                                <Trigger Property="Role" Value="SubmenuHeader">
                                    <Setter Property="Template"
					             Value="{StaticResource MenuItem.Header}"/>
                                </Trigger>
                                <Trigger Property="Role" Value="SubmenuItem">
                                    <Setter Property="Template"
					              Value="{StaticResource MenuItem.Item}"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>

                        <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type Separator}">
                                        <Rectangle Height="1" Fill="{DynamicResource MetroMenuItemSeparator}" Margin="8,6" />
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        
                    </ControlTemplate.Resources>
                    
                    <Grid x:Name="Border" Margin="8" MinWidth="150">
                        <Canvas Background="{DynamicResource MetroMenuBg}" Effect="{DynamicResource MetroDropShadow}" />
                        <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" Margin="1,4"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>